// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
  env: "cytfadmini-1gali3r244372a1f" 
 }) 
const db = cloud.database()

// 云函数入口函数
// 对于pages/zptj，修改 gifts 数据库内容
exports.main = async (event, context) => {
  try {
    var {DBname,goodsid,userInfo,...newEvent} = event
    return await db.collection(DBname)
      .doc(goodsid)
      .update({
        data: newEvent,
      })
  } catch (e) {
    console.error(e)
  }
}